<?php

require_once '../function/connection.php';

include '../view/user_panel.php';

if (isset($_SESSION['zalogowany'])) {

    connection();

 

    $query = "SELECT * FROM `SAMOCHOD_ZASTEPCZY` ";
    $result = mysql_query($query);
    $num_results = mysql_num_rows($result);

    echo'<div class="container"><table class="table table-striped table-bordered table-condensed">';
    ?>
    <tr>
        <td colspan="8"><center>Samochody zastępcze</center> </td>
    </tr>

    <?php

    echo '<tr><td>Numer</td><td>Marka</td><td>Model</td><td>Rok</td><td>Silnik</td><td>Przebieg</td><td>Numer rejestracyjny</td><td>Kolor</td><td>Dostępność</td><td>Edytuj</td><td>Usuń</td></tr>';

    for ($i = 0; $i < $num_results; $i++) {
        $row = mysql_fetch_array($result);

        echo '<tr>';
        echo '<td>' . stripslashes($row["ZAS_1_ID"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_MARKA"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_MODEL"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_ROK"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_SILNIK"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_PRZEBIEG"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_REJESTRACJA"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_KOLOR"]) . '</td>';
        echo '<td>' . stripslashes($row["ZAS_DOSTEP"]) . '</td>';
        echo '<td><a class="btn btn-info" href="/view/edit_replacement_vehicle_view.php?id=' . stripslashes($row["ZAS_1_ID"]) . '">Edytuj</a></td>';
        echo '<td><a class="btn btn-danger" href="/function/delete_replacement_vehicle.php?id=' . stripslashes($row["ZAS_1_ID"]) . '">Usuń</a></td>';
        echo '</tr>';
    }
    echo '</table>';
    
       echo '<a class="btn btn-info btn-large" href="/view/add_replacement_vehicle_view.php">Dodaj samochód</a>';
    ?>

    <?php

} else {
    session_start();
    header('Location: /');
    $_SESSION['jgrowl'] = 'Tylko zalogowani użytkownicy mają dostęp do tej cześci strony.';
}

include '../view/footer.php';
?>

